<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>DAWU WebServer Home</TITLE>
<LINK REL="stylesheet" HREF="/css/dwdoor.css" TYPE="text/css">
<link rel="stylesheet" type="text/css" href="/css/index.css">
<link rel="stylesheet" type="text/css" href="/css/custom_select.css">
<link rel="stylesheet" type="text/css" href="/css/jquery-ui.css" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/js/jquery.csf.js"></script>
<script type="text/javascript" src="/js/jquery-cookie.js"></script>
<script type="text/javascript" src="/lang/b28n.js"></script>
<script type="text/javascript" src="/js/func.js"></script>
<script type="text/javascript" src="/js/base64.min.js"></script>
<script type="text/javascript">
</script>
</HEAD>

<BODY onLoad="">
<div class="contain">

<!-- ================= NTP Settings ================= -->
<div class="sec" id="div_date">
<div class="title">网络时间设置</div>
<form method="post" name="NTP" action="/goform/NTP">
 <div class="content">
        <div>
            <ul>
                <li class="necessary  spec">
                    <span class="name">当前时间</span>
                    <span class="conn ">
                        <input class="text" type="text" size="24" name="ntpcurrenttime" value="<% getCurrentTimeASP(); %>" type="text" readonly="1">
                    </span>
                    <div class="button-container no-pad-top">
                        <button id="manNTPSyncWithHost" style="height:38px;padding:0px" name="manNTPSyncWithHost" class="button-button btn-pre" type="button"   onclick='syncWithHost()'>同步主机</button>
                    </div>
                </li>
            </ul>
       </div>
    </div>
</form>
</div>

<!-- ================= SNUM/WEBADD/CARMEADD Settings ================= -->
<div class="sec" id="div_date">
<div class="title">服务器参数设置</div>
<form method="post" id="sNuM" name="SNUM" action="/goform/setSnum">
 <div class="content">
        <div>
            <ul>
                <li class="necessary  spec">
                    <span class="names">设备编号</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="Snum"  id="Snum" maxlength="64" value="<% getSnum(); %>" type="text" >
                    </span>
                </li>
				<li class="necessary  spec">
                    <span class="names">服务器IP或网址</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="WebADDR"  id="WebADDR" maxlength="96" value="<% getWebADDR(); %>" type="text" >
                    </span>
                </li>
				<li class="necessary  spec">
                    <span class="names">WEB服务器PORT</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="9" name="WebPORT"  id="WebPORT" maxlength="8" value="<% getWebPORT(); %>" type="text" >
                    </span>
                </li>
				<!--<li class="necessary  spec">
                    <span class="names">TCP服务器PORT</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="9" name="TcpPORT"  id="TcpPORT" maxlength="8" value="" type="text" >
                    </span>
                </li>-->
                <li class="necessary">
                    <span style="width: 165px;" class="names">鉴权方式</span>
                    <select style="margin-left: 20px;" name="jqfs" id="jqfs">
                        <!-- added by initValue -->
                    </select>
                    <!--<span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="9" name="jqfs"  id="jqfs" maxlength="8" value="" type="text" >
                    </span>-->
                </li>
                <li class="necessary  spec">
                    <span class="names">结果返回路径</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="cmdresult"  id="CMDresult" maxlength="96" value="<% getcmdresult(); %>" type="text" >
                    </span>
                </li>
                <li class="necessary  spec">
                    <span class="names">实时上传路径</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="realtime"  id="REALtime" maxlength="96" value="<% getrealtime(); %>" type="text" >
                    </span>
                </li>
                <li class="necessary  spec">
                    <span class="names">定时连接路径</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="DetectDevice"  id="DETECTDevice" maxlength="96" value="<% getDetectDevice(); %>" type="text" >
                    </span>
                </li>				
				<li class="necessary  spec">
                    <span class="names">一号门摄像头 IP</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="gate0CameraADDR" id="gate0CameraADDR" maxlength="15" value="<% getgate0CameraADDR(); %>" type="text" >
                    </span>
                </li>
				<li class="necessary  spec">
                    <span class="names">一号门摄像头 PORT</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="gate0CameraPORT" maxlength="8" value="<% getgate0CameraPORT(); %>" type="text" >
                    </span>
                </li>
				<li class="necessary  spec">
                    <span class="names">二号门摄像头 IP</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="gate1CameraADDR" id="gate1CameraADDR" maxlength="15" value="<% getgate1CameraADDR(); %>" type="text" >
                    </span>
                </li>
				<li class="necessary  spec">
                    <span class="names">二号门摄像头 PORT</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="gate1CameraPORT" maxlength="8" value="<% getgate1CameraPORT(); %>" type="text" >
                    </span>
                </li>
				<li class="necessary  spec">
                    <span class="names">间隔时间（秒）</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="request_time" id="request_time" maxlength="8" value="<% getreQuesttm(); %>" type="text">
                    </span>
                </li>
				<li class="necessary  spec">
                    <span class="names">软件版本</span>
                    <span class="conn " style="margin-left: 20px;">
                        <input class="text" type="text" size="24" name="sVersion" id="sVersion" maxlength="15" value="<% getVersion(); %>" type="text" readonly="1">
                    </span>
                </li>
            </ul>
       </div>
    </div>
	
	<div class="btn-part">
        <div class="button-container">
        <button id="manSnumApply" class="button-button btn-pre" type="button"  type=submit  onclick='return SnumFormCheck();'>确定</button>
        <button id="manSnumCancel" class="button-button btn-next" type="button"  type=reset onclick=''>取消</button>              
        </div>
    </div>
</form>
</div>

<!-- ================= Gate Info ================= -->
<div class="sec">
<div class="title">门禁设置</div>
<table class="body" width="95%" border="1" cellpadding="2" cellspacing="1" id="staff_table2">
        <tr id="s0" align="center">
           <th class="title" width="10%" id="s0_0">门号</th>
           <th class="title" width="10%" id="s0_1">门名</th>
           <th class="title" width="10%" id="s0_2">区域</th>
           <th class="title" width="10%" id="s0_3">开门方式</th>
           <th class="title" width="10%" id="s0_4">开门延时</th>
           <th class="title" width="10%" id="s0_5">关门延时</th>
           <th class="title" width="10%" id="s0_6">门磁</th>
           <th class="title" width="10%" id="s0_7">反潜回</th>
           <th class="title" id="s0_8">是否考勤</th>
        </tr>
    </table>
<form method=post id="dwGateSetting" name="dwGateSetting" action="/goform/dwGateSetting" >
    <div class="content">
        <div>
            <ul>
                <li class="necessary">
                    <span class="name">门号</span>
                    <select name="gatenum" id="GateNum">
                        <option value="all">全部门</option>
                    </select>
                </li>
                <li class="necessary">
                    <span class="name">门名</span>
                     <input class="text" type="text" size="17" name="gatename" maxlength=17  value="大门"/>
                </li>
                <li class="necessary">
                    <span class="name">区域</span>
                     <input class="text" type="text" size="17"  value="总部" name="region" maxlength=17 />
                </li>
                <li class="necessary">
                    <span class="name">开门方式</span>
                    <select name="controlmethod" id="g3">
                       <option value="card">刷卡</option>
                       <option value="password">密码</option>
                       <option value="card&password">卡加密码</option>
					   <option value="cardorpass">卡或密码</option>
                    </select>
                </li>
                <li class="necessary">
                    <span class="name">开门延时</span>
                     <input class="text" type="text" size="17"  name="delayopentime" maxlength=2 value="0"/>秒
                </li>
                <li class="necessary">
                    <span class="name">关门延时</span>
                     <input class="text" type="text" size="17"  name="delayclosetime" maxlength=2 value="0" />秒
                </li>
                <li class="necessary">
                    <span class="name">门磁</span>
                   <select name="sensorstat" id="g4">
                       <option value="NG">无</option>
                       <option value="OK">有</option>
                    </select>
                </li>
              
                <li class="necessary">
                    <span class="name">是否考勤</span>
                    <select name="attendancecheck" id="g6">
                       <option value="yes">是</option>
                       <option value="no">否</option>
                    </select>
                </li>
				
				<li class="necessary">
                    <span class="name">反潜回</span>
                    <select name="antipassback" id="g7">                       
                       <option value="no">无</option>
					   <option value="yes">有</option>
                    </select>
                </li>				
				
            </ul>
        </div>
    </div>
</form>
<div class="btn-part">
    <div class="button-container">
    <button id="manApply" class="button-button btn-pre" type="button"  type=submit   onclick='dwGateSettingCheck()'>提交</button>
    <button id="manCancel" class="button-button btn-next" type="button"  type=reset   >取消</button>              
    </div>
</div>
</div>

<!-- ================= Adm Settings ================= -->
<div class="sec">
<div class="title" id="manAdmSet">账号设置</div>
<form method="post" id="account_setting" name="Adm" action="/goform/signatureChange">
 <input type="hidden" name="action_mode" value="">   
<div class="content">
        <div>
            <ul>
                <li class="necessary">
                    
                    <span class="name" id="manAdmAccount">原用户名</span>
                    <span class="conn ">
                        <input class="text" name="oadmuser" id="ouserName" size="16" maxlength="16" value="" />
                    </span>
                </li>
                <li class="necessary">
                    
                    <span class="name" id="manAdmPasswd">原密码</span>
                    <span class="conn ">
                        <input class="text" type="password" name="oadmpass" id="opassword" size="16" maxlength="32" value="">
                    </span>
                </li>
                <li class="necessary">
                    
                    <span class="name" id="mannewAccount">新用户名</span>
                    <span class="conn ">
                        <input class="text" type="text" name="admuser" id="userName" size="16" maxlength="16" value="">
                    </span>
                </li>
                <li class="necessary">
                    
                    <span class="name" id="mannewPasswd">新密码</span>
                    <span class="conn ">
                        <input class="text" type="password" name="admpass" id="password" size="16" maxlength="32" value="">
                    </span>
                </li>
                <div id="massage_text"  style="text-align:left"></div>
                 
            </ul>
       </div>
    </div>

<div class="btn-part">
        <div class="button-container">
        <button id="manAdmApply" class="button-button btn-pre" type="button"   onclick='return AdmFormCheck()'>确定</button>
        <button id="manAdmCancel" class="button-button btn-next" type="button"  onclick='window.location.reload()'>取消</button>              
        </div>
    </div>
</form>
</div>

<!-- ================= Download ================= -->
<br />
<div class="sec">
<div class="title">导出数据库</div>
<form method="post" id="down_database" name="Dwdownload" action="/cgi-bin/dwdownload.sh">
 <div class="content">
        <div>
            <ul>
                <li class="necessary  spec">
                    <span class="name">导出数据库</span>
                    <div class="button-container">
                        <button id="setmanExpSetDownload" style="height:38px;padding:0px" name="Download" class="button-button btn-pre" type="submit"   onclick='document.getElementById("down_database").submit()'>导出数据库</button>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</form>

<form method="post" id="ImportDb" action="/cgi-bin/upload_db.cgi" enctype="multipart/form-data" target="hiddenframe2">
         <div class="content">
            <div>
                <ul>
                    <li class="necessary">
                        <span class="name">选择数据库文件</span>
                        <input type="File" id="fileName" class="text" name="filename" size="20" maxlength="256" onchange="return checkfiletype(this);">
                    </li>
                </ul>
            </div>
        </div>
        <div class="btn-part">
            <div class="button-container">
            <button id="mandbImport" class="button-button btn-pre" type="button"  type=submit   onclick='return importDatabaseSubmit()'>上传</button>
            <button id="mandbCancel" class="button-button btn-next" type="button"  type=reset   >取消</button>              
            </div>
        </div>
</form>

<!--<form method="post" id="Importwj" action="/cgi-bin/upload_file.cgi" enctype="multipart/form-data" target="hiddenframe2">
         <div class="content">
            <div>
                <ul>
                    <li class="necessary">
                        <span class="name">选择文件</span>
                        <input type="File" id="wjName" class="text" name="filename" size="20" maxlength="256" onchange="return checkwjtype(this);">
                    </li>
                </ul>
            </div>
        </div>
        <div class="btn-part">
            <div class="button-container">
            <button id="manwjImport" class="button-button btn-pre" type="button"  type=submit   onclick='return importwjSubmit()'>上传</button>
            <button id="manwjCancel" class="button-button btn-next" type="button"  type=reset   >取消</button>              
            </div>
        </div>
</form>-->
</div>		

<div class="sec">
<div class="title" id="manLangSet">语言设置</div>

 <!-- ================= Langauge Settings =================--> 
<form method="post" name="Lang" action="/goform/setSysLang">
  <div class="content">
        <div>
            <ul>
                <li class="necessary">
                    <span class="name" id="manSelectLang">选择语言</span>
                     <select name="langSelection" id="langSelection">
                        <!-- added by initValue --> 
                      </select>
                </li>
            </ul>
       </div>
   </div>
   <div class="btn-part">
        <div class="button-container cnter">
        <button id="manLangApply" class="button-button btn-pre" type="button"   onclick='return setLanguage();'>确定</button>
        <button id="manLangCancel" class="button-button btn-next" type="button"  onclick='window.location.reload()'>取消</button>              
        </div>
    </div>
</form>
</div>

<!-- ================= Password Settings ================= 
<div class="sec" id="div_opendoor_pwd_cnt">
<div class="title">开门密码设置</div>
<form method="post" id="passwordset" name="passwordset" action="/goform/signatureSet">
 <div class="content">
        <div>
            <ul>
                <li class="necessary">
                    <span class="name">开门密码</span>
                    <span class="conn ">
                        <input class="text"  type="text" id="P2" size="16" maxlength="6" name="password" >
                    </span>
                </li>
            <li class="necessary">
                    <span class="name">胁迫密码</span>
                    <span class="conn ">
                        <input class="text"  type="text" name="forcepass" id="P3" size="16" maxlength="6" value="" type="text" >
                    </span>
                </li>
            </ul>
       </div>
    </div>
    <div class="btn-part">
        <div class="button-container">
        <button id="manNTPApply" class="button-button btn-pre" type="button"   onclick='passwordsetCheck();'>确定</button>
        <button id="manNTPCancel" class="button-button btn-next" type="button"  onclick='window.location.reload()'>取消</button>              
        </div>
    </div>
    </form>
</div>-->
</div>
</BODY>
<script type="text/javascript">
Butterlate.setTextDomain("admin");

function dwGateSettingCheck(){
	var delayopentime=document.dwGateSetting.delayopentime.value;
    var delayclosetime=document.dwGateSetting.delayclosetime.value;
    if(delayopentime=="")
    {
        if($.cookie('language') === "en")
		    alert( "Please input delayopentime." );
		if($.cookie('language') != "en")
		    alert( "请输入开门延时。" );
        document.dwGateSetting.delayopentime.focus();
        return false;
    }
	if(delayclosetime=="")
    {
        if($.cookie('language') === "en")
		    alert( "Please input delayclosetime." );
		if($.cookie('language') != "en")
		    alert( "请输入关门延时。" );
        document.dwGateSetting.delayclosetime.focus();
        return false;
    }
	if(!isAllNum(delayopentime))
    {
        if($.cookie('language') === "en")
		    alert( "Only mumber can be input." );
		if($.cookie('language') != "en")
		    alert( "开门延时只能是数字，请重新输入。" );
        document.dwGateSetting.delayopentime.focus();
        return false;
    }
	if(!isAllNum(delayclosetime))
    {
        if($.cookie('language') === "en")
		    alert( "Only mumber can be input." );
		if($.cookie('language') != "en")
		    alert( "关门延时只能是数字，请重新输入。" );
        document.dwGateSetting.delayclosetime.focus();
        return false;
    }
	var gatename=document.dwGateSetting.gatename.value;
	var region=document.dwGateSetting.region.value;
	if(gatename=="")
    {
        if($.cookie('language') === "en")
		    alert( "Please input gatname." );
		if($.cookie('language') != "en")
		    alert( "请输入开门门名。" );
        document.dwGateSetting.gatename.focus();
        return false;
    }
	if(region=="")
    {
        if($.cookie('language') === "en")
		    alert( "Please input region." );
		if($.cookie('language') != "en")
		    alert( "请输入区域。" );
        document.dwGateSetting.region.focus();
        return false;
    }
	if(isRealLength(gatename)>12)
    {
        alert('门名太长，请重新输入。');
        document.dwGateSetting.gatename.focus();
        return false;
    }
	if(isRealLength(region)>12)
    {
        alert('区域名字太长，请重新输入。');
        document.dwGateSetting.region.focus();
        return false;
    }
	document.getElementById("dwGateSetting").submit();
}

function initTranslation()
{
    var e = document.getElementById("manLangApply");
    e.value = _("admin apply");	
	e = document.getElementById("manLangCancel");
    e.value = _("admin cancel");
	e = document.getElementById("manLangSet");
	e.innerHTML = _("man language setting");
	e = document.getElementById("manSelectLang");
	e.innerHTML = _("man select language");
	e = document.getElementById("manAdmSet");
	e.innerHTML = _("man admin setting");
	e = document.getElementById("manAdmAccount");
	e.innerHTML = _("man admin account");
	e = document.getElementById("manAdmPasswd");
	e.innerHTML = _("man admin passwd");
	e = document.getElementById("mannewAccount");
	e.innerHTML = _("man new account");
	e = document.getElementById("mannewPasswd");
	e.innerHTML = _("man new passwd");
}

function alertContents()
{
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
			// refresh
			window.location.reload();
        } else {
            alert('There was a problem with the request.');
        }
    }
}

function makeRequest(url, content) 
{
    http_request = false;
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = alertContents;
    http_request.open('POST', url, true);
    http_request.send(content);
}

function setLanguage()
{
	document.cookie="language="+document.Lang.langSelection.value+"; path=/";
//	console.dir(document.cookie);
//	alert('1:'+document.cookie);
    document.Lang.submit();
//	alert('2:'+document.Lang.value);
//	window.location.reload();
	return true;
}

function passwordsetCheck()
{
    var password=document.passwordset.password.value;
    var forcepass=document.passwordset.forcepass.value;
    if(password=="")
    {
        if($.cookie('language') === "en")
		    alert( "Please input password." );
		if($.cookie('language') != "en")
        alert( "请输入开门密码。" );
        document.passwordset.password.focus();
        return false;
    }
    if(forcepass=="")
    {
        if($.cookie('language') === "en")
		    alert( "Please input forcepassword." );
		if($.cookie('language') != "en")
        alert( "请输入胁迫密码。" );
        document.passwordset.forcepass.focus();
        return false;
    }
    if(!isAllNum(password))
    {
        if($.cookie('language') === "en")
		    alert( "Only mumber can be input." );
		if($.cookie('language') != "en")
        alert( "开门密码只能是数字，请重新输入。" );
        document.passwordset.password.focus();
        return false;
    }
    if(!isAllNum(forcepass))
    {
        if($.cookie('language') === "en")
		    alert( "Only mumber can be input." );
		if($.cookie('language') != "en")
        alert( "胁迫密码只能是数字，请重新输入。" );
        document.passwordset.forcepass.focus();
        return false;
    }
	
    document.getElementById("passwordset").submit();
}

function syncWithHost()
{
    var currentTime = new Date();

    var seconds = currentTime.getSeconds();
    var minutes = currentTime.getMinutes();
    var hours = currentTime.getHours();
    var month = currentTime.getMonth() + 1;
    var day = currentTime.getDate();
    var year = currentTime.getFullYear();

    var seconds_str = " ";
    var minutes_str = " ";
    var hours_str = " ";
    var month_str = " ";
    var day_str = " ";
    var year_str = " ";

    if(seconds < 10)
        seconds_str = "0" + seconds;
    else
        seconds_str = ""+seconds;

    if(minutes < 10)
        minutes_str = "0" + minutes;
    else
        minutes_str = ""+minutes;

    if(hours < 10)
        hours_str = "0" + hours;
    else
        hours_str = ""+hours;

    if(month < 10)
        month_str = "0" + month;
    else
        month_str = ""+month;

    if(day < 10)
        day_str = "0" + day;
    else
        day_str = day;

    var tmp =  month_str + day_str + hours_str + minutes_str + seconds_str + year + " ";
    
    makeRequest("/goform/NTPSyncWithHost", tmp);    
}

function checkfiletype(obj)
{
    var name=obj.value;
//	alert('name1:'+name);
	name=name.substring(name.lastIndexOf("\\")+1);
//	alert('name2:'+name);
    if(name !="dwdoor.db" )
	{
        alert("请选择正确的数据库文件上传(文件名：dwdoor.db)。");
        obj.value="";
        return false;
    }
	var fileSize = getFileSize(obj);
    if((fileSize / 1024) > 1024)
    {
    	alert("数据库文件不能大于1M.");
        obj.value="";
        return false;
    }
	return true;
}

function checkwjtype(obj)
{  
	return true;
}

function importDatabaseSubmit()
{
	var fileNamecheck = document.getElementById("fileName");
	if(!fileNamecheck)
	{
	    alert("请先正确选择数据库文件。");
		return false;
	}
	var r2 = checkfiletype(fileNamecheck);
    if(r2 == false)
    {
	    return false;
	}	
	var r = confirm("确定要导入数据库，请务必：1、先导出并备份数据库文件。2、请仔细检查待上传数据库文件是否正确。数据库一旦上传覆盖将不能恢复原来数据库文件，上传错误数据库文件可能导致严重后果。");    
	if (r==true)
    {
    	document.getElementById("ImportDb").submit();
    }
  	else
    {
    	return false;
    }
}

function importwjSubmit()
{
	document.getElementById("Importwj").submit();
	return;
}

function settab()
{
    var table2 = document.getElementById('staff_table2');
    var rowslen = table2.rows.length;
    for(var j=rowslen-1;j>=1;j--)
	{
	    table2.deleteRow(j);
	}
	var gatetab = <%dwGateGet();%>;
//	alert(gatetab);
	var nrows = 4;
	var ncols = 9;
	if(gatetab.nrows!="") nrows=gatetab.nrows;
	if(gatetab.ncols!="") ncols=gatetab.ncols;
	for(var l=1;l<=nrows;l++)
	{		    
        inrow=table2.insertRow(l);			
	    inrow.setAttribute("id","s" + l);
		inrow.setAttribute("align","center");
        for(var m=0;m<=(ncols-1);m++)
        {
		    var incell = inrow.insertCell(m);
		    if(m==0)
			{
				if(l==1 && $.cookie('language') === "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'Door 1 Entrance'+'</td>';
				if(l==1 && $.cookie('language') != "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'一号门进口'+'</td>';
				if(l==2 && $.cookie('language') === "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'Door 1 Eixt'+'</td>';
				if(l==2 && $.cookie('language') != "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'一号门出口'+'</td>';
				if(l==3 && $.cookie('language') === "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'Door 2 Entrance'+'</td>';
				if(l==3 && $.cookie('language') != "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'二号门进口'+'</td>';
				if(l==4 && $.cookie('language') === "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'Door 2 Eixt'+'</td>';
				if(l==4 && $.cookie('language') != "en") incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+'二号门出口'+'</td>';
		    }
		    else if(m==3)
		    {
		    	if(gatetab['s'+l+'_'+m] == "password")
		    	{
		    		 incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">密码</td>';		
		    	}
		    	if(gatetab['s'+l+'_'+m] == "card")
		    	{
		    		incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">刷卡</td>';		
		    	}
                if(gatetab['s'+l+'_'+m] == "card&password"){
                    incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">卡加密码</td>';
                }
                if(gatetab['s'+l+'_'+m] == "cardorpass"){
                    incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">卡或密码</td>';
                }
		    }
		    else if(m==6)
		    {
		    	if(gatetab['s'+l+'_'+m] == "NG")
		    	{
		    		if($.cookie('language') != "en")
		    		 incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">无</td>';		
					if($.cookie('language') == "en")
					    incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">No</td>';
		    	}
		    	else
		    	{
		    		if($.cookie('language') != "en")
		    		 incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">有</td>';		
					if($.cookie('language') == "en")
                        incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">OK</td>';					
		    	}
		    }
			else if(m==7)
			{
				if(gatetab['s'+l+'_'+m] == "no")
		    	{
		    		if($.cookie('language') != "en")
		    		 incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">无</td>';		
					if($.cookie('language') == "en")
					    incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">No</td>';
		    	}
		    	else
		    	{
		    		if($.cookie('language') != "en")
		    		 incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">有</td>';		
					if($.cookie('language') == "en")
                        incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">OK</td>';					
		    	}
			}
		    else if(m==8)
		    {
		    	if(gatetab['s'+l+'_'+m] == "yes")
		    	{
		    		 incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">是</td>';		
		    	}
		    	else
		    	{
		    		 incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">否</td>';		
		    	}
		    }
		    else
            {
			    incell.innerHTML = '<td><class="head2" id="s'+l+'_'+m+'">'+gatetab['s'+l+'_'+m]+'</td>';
			}			
		}			
	}
}

function AdmFormCheck()
{
	document.Adm.action_mode.value = 'apply';
	var admuser=document.Adm.admuser.value;
	var admpass=document.Adm.admpass.value;
    var oadmuser=document.Adm.oadmuser.value;
	var oadmpass=document.Adm.oadmpass.value;
	if(oadmuser=="")
	{
		alert( "请输入原用户名。" );
		document.Adm.oadmuser.focus();
		return false;
	}
	if(oadmpass=="")
	{
		alert( "请输入原密码。" );
		document.Adm.oadmpass.focus();
		return false;
	}
	if(admuser=="")
	{
		alert( "请输入新用户名。" );
		document.Adm.admuser.focus();
		return false;
	}
	if(admpass=="")
	{
		alert( "请输入新密码。" );
		document.Adm.admpass.focus();
		return false;
	}
	if(oadmpass.match(/^[0-9A-Za-z_.@*-]{1,32}$/)==null)
    {
    	//$('#massage_text').text("只能输入数字、字母和_.@-*字符。");
    	alert("原密码只能输入数字、字母和_.@-*字符，请重新输入");
    	document.Adm.oadmpass.focus();
        return false;
    }
    if(admpass.match(/^[0-9A-Za-z_.@*-]{1,32}$/)==null)
    {
    	//$('#massage_text').text("只能输入数字、字母和_.@-*字符。");
    	alert("新密码只能输入数字、字母和_.@-*字符，请重新输入");
    	document.Adm.admpass.focus();
        return false;
    }

    oadmpass = MD5(oadmpass);
    document.Adm.oadmpass.value = base64encode(utf16to8(oadmpass));
    admpass = MD5(admpass);
    document.Adm.admpass.value = base64encode(utf16to8(admpass));

    var loginData = "{\"oadmuser\":\"" + document.Adm.oadmuser.value + "\",\"oadmpass\":\""
        + document.Adm.oadmpass.value+"\",\"admuser\":\"" + document.Adm.admuser.value + "\",\"admpass\":\""
        + document.Adm.admpass.value+"\"}";
    var authSend=base64encode(utf16to8(loginData));
        $.ajax({
        url: "/goform/signatureChange",
            type: "POST",
            timeout: 180000,
            data: authSend,
            dataType: "text",
            error: function() {
			     $('#massage_text').text('网络错误。'); 
                return false;
            },
            complete: function() {
              if (status === 'timeout') {
                this.abort();
              }
            },
            success: function(authReturn64) {
				var authReturn;
            authReturn = jQuery.parseJSON(Base64.decode(authReturn64));
                if(authReturn.result === "success")
				{
                       alert('用户名、密码变更成功。');
                }else if(authReturn.result === "deny1")
				{
    
                    alert('原用户名错，请重新输入。');
                    return false;
                }else if(authReturn.result === "deny2")
				{
                    alert('原密码错，请重新输入。');
                    return false;
                }else if(authReturn.result === "deny3")
				{
                    alert('请输入原用户名。');
                    return false;
                }else if(authReturn.result === "deny4")
				{
                    alert('请输入原密码。');
                    return false;
                }else if(authReturn.result === "deny5")
				{
                    alert('出错了。重启或联系管理员。');
                    return false;
                }else if(authReturn.result === "deny6")
				{
                    alert('用户名或密码太长。');
                    return false;
                }else if(authReturn.result === "deny7")
                {
                    alert('请输入新用户名。');
                    return false;
                }else if(authReturn.result === "deny8")
                {
                    alert('请输入新密码。');
                    return false;
            }else
                {
                    alert('错误的返回值。');
                    return false;
                }
            }
        });

	return true;
}

function SnumFormCheck()
{
    var serialNum	       =document.SNUM.Snum.value;
	var serverIP 	       =document.SNUM.WebADDR.value;
	var serverPort	       =document.SNUM.WebPORT.value;
//	var tcpPort	           =document.SNUM.TcpPORT.value;
    var jqfs               =document.SNUM.jqfs.value;
	var gate0cameraIP      =document.SNUM.gate0CameraADDR.value;
	var gate0cameraPort	   =document.SNUM.gate0CameraPORT.value;
	var gate1cameraIP      =document.SNUM.gate1CameraADDR.value;
	var gate1cameraPort	   =document.SNUM.gate1CameraPORT.value;
	var reQuesttm          =document.SNUM.request_time.value;
	var CmdResult	       =document.SNUM.CMDresult.value;
	var RealTime	       =document.SNUM.REALtime.value;
	var DetectDevice       =document.SNUM.DETECTDevice.value;
	
	if(CmdResult=="")
    {    
		alert( "请输入结果返回路径。" );
        document.SNUM.CMDresult.focus();
        return false;
    }
	if(RealTime=="")
    {    
		alert( "请输入实时上传路径。" );
        document.SNUM.REALtime.focus();
        return false;
    }
	if(DetectDevice=="")
    {    
		alert( "请输入定时连接路径。" );
        document.SNUM.DETECTDevice.focus();
        return false;
    }
	if(serialNum=="")
    {    
		alert( "请输入设备编码。" );
        document.SNUM.Snum.focus();
        return false;
    }
	if(serverIP=="")
    {    
		alert( "请输入服务器 IP。" );
        document.SNUM.WebADDR.focus();
        return false;
    }
/*    if(tcpPort=="")
    {    
	    alert( "请输入TCP服务器 PORT。" );
        document.SNUM.tcpPort.focus();
        return false;
    }*/
    if(jqfs=="")
    {    
        alert( "请输入鉴权方式。" );
        document.SNUM.jqfs.focus();
        return false;
    }
	if(serverPort=="")
    {    
	    alert( "请输入WEB服务器 PORT。" );
        document.SNUM.WebPORT.focus();
         return false;
    }
	if(gate0cameraPort=="")
    {    
	    alert( "请输入一号门摄像头 PORT。" );
        document.SNUM.gate0CameraPORT.focus();
         return false;
    }
	if(gate0cameraIP=="")
    {    
		alert( "请输入一号门摄像头 IP。" );
        document.SNUM.gate0CameraADDR.focus();
        return false;
    }
	if(gate1cameraPort=="")
    {    
	    alert( "请输入二号门摄像头 PORT。" );
        document.SNUM.gate1CameraPORT.focus();
         return false;
    }
	if(gate1cameraIP=="")
    {    
		alert( "请输入二号门摄像头 IP。" );
        document.SNUM.gate1CameraADDR.focus();
        return false;
    }
    if(serialNum.length<2||serialNum.length>96)
    {
        alert( "设备编号输入错误，只能是2-96位字符，请重新输入。" );
        document.SNUM.Snum.focus();
        return false;
    }
	
    if(!checkAllNum(reQuesttm)||reQuesttm.length<1)
    {
        alert( "间隔时间输入错误，只能是1-8位数字，请重新输入。" );
        document.SNUM.Snum.focus();
        return false;
    }
/*    if(!checkIp(document.SNUM.WebADDR))
    {
        alert('服务器IP输入错误，请重新输入。');
        document.SNUM.WebADDR.focus();
        return false;
    }*/
    if(!valid_port0(serverPort))
    {
        alert('WEB服务器PORT输入错误，请重新输入。\n温馨提示：只能输入1-65534之间的整数。');
        document.SNUM.WebPORT.focus();
        return false;
    }
/*	if(!valid_port0(tcpPort))
    {
        alert('TCP服务器PORT输入错误，请重新输入。\n温馨提示：只能输入1-65534之间的整数。');
        document.SNUM.tcpPort.focus();
        return false;
    }*/
	if(!valid_port0(gate0cameraPort))
    {
        alert('一号门摄像头PORT输入错误，请重新输入。\n温馨提示：只能输入1-65534之间的整数。');
        document.SNUM.gate0WebPORT.focus();
        return false;
    }
    if(!checkIp12(document.SNUM.gate0CameraADDR))
    {
        alert('一号门摄像头IP输入错误，请重新输入。');
        document.SNUM.gate0CameraADDR.focus();
        return false;
    }
    if(!valid_port0(gate1cameraPort))
    {
        alert('二号门摄像头PORT输入错误，请重新输入。\n温馨提示：只能输入1-65534之间的整数。');
        document.SNUM.gate1WebPORT.focus();
        return false;
    }
    if(!checkIp12(document.SNUM.gate1CameraADDR))
    {
        alert('二号门摄像头IP输入错误，请重新输入。');
        document.SNUM.gate1CameraADDR.focus();
        return false;
    }
       
    document.getElementById("sNuM").submit();
}

function initValue() 
{
	var lang_element = document.getElementById("langSelection");
	initTranslation();
	lang_element.options.length = 0;
    var jqfs = document.getElementById("jqfs");    
    jqfs.options.length = 0;
    var jqfszhi = "<%getjqfs();%>";
	if ($.cookie('language') == "en")
	{
	    lang_element.options[lang_element.length] = new Option('Simple Chinese', 'zhcn');
	    lang_element.options[lang_element.length] = new Option('English', 'en');
        if( jqfszhi== "bendi")
        {
            jqfs.options[jqfs.length] = new Option('Local auth', 'bendi');
            jqfs.options[jqfs.length] = new Option('Central auth', 'jizhong');
        }else
        {
            jqfs.options[jqfs.length] = new Option('Central auth', 'jizhong');
            jqfs.options[jqfs.length] = new Option('Local auth', 'bendi');
        }
	}else
	{
	    lang_element.options[lang_element.length] = new Option('英文', 'en');
		lang_element.options[lang_element.length] = new Option('中文', 'zhcn');
        if( jqfszhi == "bendi")
        {
            jqfs.options[jqfs.length] = new Option('本地鉴权', 'bendi');
            jqfs.options[jqfs.length] = new Option('集中鉴权', 'jizhong');
        }else
        {
            jqfs.options[jqfs.length] = new Option('集中鉴权', 'jizhong');
            jqfs.options[jqfs.length] = new Option('本地鉴权', 'bendi');
        }
	}
	settab();
}

$(document).ready(function(){
  initValue();
  $('#langSelection').customSelectForm({index:1});
  $('#GateNum').customSelectForm({index:2});
  $('#g4').customSelectForm({index:3});
  $('#g5').customSelectForm({index:4});
  $('#g6').customSelectForm({index:5});
  $('#g3').customSelectForm({index:6});
  $('#jqfs').customSelectForm({index:13});
});   

$(function(){
		if($.cookie('logon') === "null" || !$.cookie('logon')){
		    top.window.location.pathname = '/login.asp';
		}
		
  	function checkCookie(){
	  	var a = $.cookie('logon') === "null" || !$.cookie('logon');
	  	if(a){
	  		top.window.location.pathname = '/login.asp';
	  	}else{
		    var date = new Date();
		    date.setTime(date.getTime() + (60 * 60 * 1000));
		    $.cookie('logon',true,{expires: date});		 
		}
	  }
	});
</script>
</HTML>

